package com.example.shop.eventbus;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class Main2Activity extends AppCompatActivity {
    private TextView mCtv;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        mCtv = (TextView) findViewById(R.id.Ctv);
    }

    public void go1(View v) {
       MyThread thread=new MyThread();
        thread.start();

    }
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void add(Lancer lancer){
        mCtv.setText("枪托莉雅"+lancer.count+"");

    }
    @Override
    protected void onStop() {
        super.onStop();
        EventBus.getDefault().unregister(this);
    }

    @Override
    protected void onStart() {
        super.onStart();
        EventBus.getDefault().register(this);
    }
}
